
let objOk = {
	name: '张三',
	then(resolve, reject) {
		resolve('objOk ok')
	}
}


let objFailed = {
	name: '李四',
	then(resolve, reject) {
		reject('objFailed err')
	}
}

// thenable
;(() => {

	let p1 = Promise.resolve(objOk)
	setTimeout(() => {
		console.log(p1)
	})
	p1.then(value=> {
		console.log('p1', value)
	}).catch(err => {
		console.warn('p1', err)
	})


	let p2 = Promise.resolve(objFailed)
	setTimeout(() => {
		console.log(p2)
	})
	p2.then(value=> {
		console.log('p2', value)
	}).catch(err => {
		console.warn('p2', err)
	})
})



;(() => {

	let p1 = Promise.reject(objOk)
	setTimeout(() => {
		console.log(p1)
	})
	p1.then(value=> {
		console.log('p1', value)
	}).catch(err => {
		console.warn('p1', err)
	})


	let p2 = Promise.reject(objFailed)
	setTimeout(() => {
		console.log(p2)
	})
	p2.then(value=> {
		console.log('p2', value)
	}).catch(err => {
		console.warn('p2', err)
	})
})()